{% extends "resource.html" %}

{% load ratings %}
{% load tags %}

{% block title %}DAMN - {{ asset.subName }}{% endblock %}

{% block head %}
<script id="tagTemplate" type="text/x-jquery-tmpl">
    <div>
      <a class="tag" href="/search/?tag=${id}">${category} - ${type} - ${count}</a>
      {% templatetag openvariable%}if owner{% templatetag closevariable%}
        <a class="tag-remove" href="{{asset|tag_remove_url_template:'${id}'}}">X</a>
      {% templatetag openvariable%}/if{% templatetag closevariable%}
    </div>
</script>
<script id="tagTemplate2" type="text/x-jquery-tmpl">
    <div><a class="tag-add" href="{{asset|tag_add_url_template:'${id}'}}">${category} - ${type} - ${count}</a> </div>
</script>
<script type="text/javascript">
  $(document).ready(function () {
    var load_tags = function () {
      $('#asset_tags').damn_load('{% url 'tags.views.asset_tags' as_id=asset.id %}', '#tagTemplate', 'No tags');
    };
    load_tags();
    {% if user.is_authenticated %}
      $('#all_tags').damn_load('{% url 'tags.views.tags' %}', '#tagTemplate2', 'No tags');
      $('.tag-add').damn_click(function() { load_tags(); });
      $('.tag-remove').damn_click(function() { load_tags(); });
    {% endif %}
  });
</script>
{% endblock %}

{% block left.extra %}
<h2>Licenses:</h2>
  <!--<div class="field-items">
  <div class="field-item even">
  <div class="license-icon">
  <a href="http://creativecommons.org/licenses/by/3.0/"><img title="" alt="" src="http://opengameart.org/sites/default/files/license_images/cc-by.png"><div class="license-name">CC-BY 3.0</div></a>
  </div></div><div class="field-item odd"><div class="license-icon">
  <a href="http://creativecommons.org/licenses/by-sa/3.0/"><img title="" alt="" src="http://opengameart.org/sites/default/files/license_images/cc-by-sa.png"><div class="license-name">CC-BY-SA 3.0</div></a>
  </div></div><div class="field-item even"><div class="license-icon">
  <a href="http://www.gnu.org/licenses/gpl-3.0.html"><img title="" alt="" src="http://opengameart.org/sites/default/files/license_images/gpl.png"><div class="license-name">GPL 3.0</div></a></div></div>
  </div>-->
{% endblock %}

{% block right %}

<div class="row">
  <div class="span10">
    <span class="title">Asset: {{ asset.subName }} {{ asset.id }}</span>
  </div>
  <div class="span2">
    <div class="sound_stars">
       <ul class="star-rating">
           <li class="current-rating" style="width:{{asset.rating_percent}}%;">Currently {{asset.avg_rating}}/5 Stars.</li>
           <li><a href="{{asset|rating_url:"1"}}" title="pretty bad :-(" class="one-star{% if not user.is_authenticated or user == asset.file.author %}_not_logged_in{% endif %}">1</a></li>
           <li><a href="{{asset|rating_url:"2"}}" title="quite good" class="two-stars{% if not user.is_authenticated or user == asset.file.author %}_not_logged_in{% endif %}">2</a></li>
           <li><a href="{{asset|rating_url:"3"}}" title="good :-)" class="three-stars{% if not user.is_authenticated or user == asset.file.author %}_not_logged_in{% endif %}">3</a></li>
           <li><a href="{{asset|rating_url:"4"}}" title="very good" class="four-stars{% if not user.is_authenticated or user == asset.file.author %}_not_logged_in{% endif %}">4</a></li>
           <li><a href="{{asset|rating_url:"5"}}" title="amazing :-o" class="five-stars{% if not user.is_authenticated or user == asset.file.author %}_not_logged_in{% endif %}">5</a></li>
       </ul>
    </div>
  </div>
</div>
<div class="row">
  <div class="span5">
    <img class="model_preview" src="/api/assets/{{ asset.id }}/transcode/?format=image/png&sizex=256&sizey=256" />
  </div>
  <div class="span7">
    <div class="block">
      <h1>Version:  {{ asset.version }}</h1>
      {% if asset.ancestor %}
       Previous revision: <a href="/assets/{{ asset.ancestor.id }}/"> {{ asset.ancestor.subName }}</a>
      {% endif %}
      {% if not asset.is_latest %}
       Next revision: <a href="/assets/{{ asset.descendant.id }}/"> {{ asset.descendant.subName }}</a>
       <span class="label notice">Newest: <a href="/assets/{{ asset.latest.id }}/"> {{ asset.latest.subName }}</a><span>
      {% else %}
       <span class="label success">Latest</a><span>
      {% endif %}
    </div>
    <div class="block">
      <h1>Format:</h1>
      {{ asset.format.type.name }} - {{ asset.format.name }}
    </div>
    <div class="block">
      <h1>File:</h1>
      <div class="file"><a href="/files/{{ asset.file.id }}/"> {{ asset.file.file_name }}</a></div>
    </div>
  </div>
</div>

  

      
    <div class="block tags">
      <h1>Tags:</h1>
      <div id="asset_tags"></div>
    </div>
    
    {% if user.is_authenticated %}
      <div class="block tags">
        <h1>Add Tags:</h1>
        <div id="all_tags"></div>
      </div>
    {% endif %}

    
    <div class="block">
      <h1>Favored by:</h1>
      {% for favored in favoreds.all %}
        <a href="{% url 'profiles.views.profile' user_id=favored.user.id %}/">{{ favored.user }}</a> 
      {% empty %}
        None
      {% endfor %}
    </div>
    
    
    
    <div class="block">
      <h1>Dependencies:</h1>
      {% for dep in asset.dependencies.all %}
        <a href="{% url 'webgui.views.asset' as_id=dep.id %}">{{ dep.subName }}</a> 
      {% empty %}
        No dependencies
      {% endfor %}
    </div>
    
    <div class="block">
      <h1>Transcode:</h1>
      {% for format in formats %}
        <div class="format">
          <a class="transcode" href="{% url 'assets.views.transcode' as_id=asset.id %}?format={{ format.format_esc }}">{{ format.format_esc }}</a> {{ format.template }}
        </div>
      {% empty %}
        No formats
      {% endfor%}
    </div>
    
{% endblock %}
